package com.hisysteTopet.hisystepet.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hisysteTopet.hisystepet.bean.Notice;
import org.apache.ibatis.annotations.*;

import java.util.Date;
import java.util.List;

@Mapper
public interface NoticeMapper extends BaseMapper<Notice> {

        // 降序查询
    @Select("SELECT * FROM notice ORDER BY `date` DESC;")
    public List<Notice> selectListNotice();

    // 根据Id修改公告内容
    @Update("UPDATE notice SET message = #{noticeMessage} WHERE id = #{noticeId} ")
    public void updateNoticeMessage(String noticeMessage,Integer noticeId);

    // 根据Id删除公告信息
    @Delete("DELETE FROM notice WHERE id = #{noticeId}")
    public void deleteNoticeMessage(Integer noticeId);

    // 添加新的公告信息
    @Insert("INSERT INTO notice(message,`date`) " +
            "VALUE(#{noticeMessage},#{date})")
    public void insertNoticeMessage(String noticeMessage, Date date);

}
